package bjtuoj;

import java.util.Scanner;

/**
 * ClassName: Homework_1_3
 * Description:
 * date: 2021-09-25 21:02
 *
 * @author liyifan
 */
public class Homework_1_C {


    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        scanner.close();
        boolean[] use = new boolean[21];
        long[] jc = new long[21];
        m--;
        jc[0] = 1;
        for (int i = 1;i <=n;i++) {
            jc[i] = jc[i - 1] * i;
        }
        for (int j,i = 1; i <= n;i++){
            long temp = m / jc[n - i];
            m %= jc[n - i];
            for (j = 1;j <= n;j++) {
                if (!use[j]) {
                    if (temp == 0)
                        break;
                    temp--;
                }
            }
            use[j] = true;
            System.out.print(j + " ");
        }
    }
}
